import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  // {
  //   title: '项目编号',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'projectCode'
  // },
  // {
  //   title: '项目简称',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'projectShortName'
  // },
  {
    title: '项目名',
    align: "center",
    sorter: true,
    dataIndex: 'projectName'
  },
  {
    title: '主管部门',
    align: "center",
    sorter: true,
    dataIndex: 'deptId_dictText'
  },
  {
    title: '金科项目经理',
    align: "center",
    sorter: true,
    dataIndex: 'projectManager_dictText'
  },
  {
    title: '项目负责人',
    align: "center",
    sorter: true,
    dataIndex: 'projectOwner_dictText'
  },
  {
    title: '行方负责人',
    align: "center",
    sorter: true,
    dataIndex: 'bankOwner'
  },
  {
    title: '测试负责人',
    align: "center",
    sorter: true,
    dataIndex: 'testOwner_dictText'
  },
  {
    title: '项目所属',
    align: "center",
    dataIndex: 'projectOwnCata_dictText'
  },
  {
    title: '项目分类',
    align: "center",
    sorter: true,
    dataIndex: 'projectCata_dictText'
  },
  {
    title: '软开科室',
    align: "center",
    sorter: true,
    dataIndex: 'department'
  },
  {
    title: '业务部门',
    align: "center",
    sorter: true,
    dataIndex: 'businessUnit'
  },
  {
    title: '启用状态',
    align: "center",
    sorter: true,
    dataIndex: 'status',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}]);
     },
  },
  {
    title: '重点项目',
    align: "center",
    sorter: true,
    dataIndex: 'importantProject',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}]);
     },
  },
  {
    title: '开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'startTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'endTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '描述',
    align: "center",
    sorter: true,
    dataIndex: 'description'
  },
  {
    title: '创建人',
    align: "center",
    sorter: true,
    dataIndex: 'createBy'
  },
  {
    title: '创建时间',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    sorter: true,
    dataIndex: 'updateBy'
  },
  {
    title: '更新时间',
    align: "center",
    sorter: true,
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目编号",
    field: 'projectCode',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "项目简称",
    field: 'projectShortName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "项目名",
    field: 'projectName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "主管部门",
    field: 'deptId',
    component: 'JSelectDept',
    //colProps: {span: 6},
  },
  {
    label: "金科项目经理",
    field: 'projectManager',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "项目负责人",
    field: 'projectOwner',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "行方负责人",
    field: 'bankOwner',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "测试负责人",
    field: 'testOwner',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "项目分类",
    field: 'projectCata',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "project_cata"
    },
    //colProps: {span: 6},
  },
  {
    label: "软开科室",
    field: 'department',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "业务部门",
    field: 'businessUnit',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "启用状态",
    field: 'status',
    component: 'JSwitch',
    componentProps:{
    },
    //colProps: {span: 6},
  },
  {
    label: "描述",
    field: 'description',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "创建人",
    field: 'createBy',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目编号',
    field: 'projectCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目编号!'},
             ];
    },
  },
  {
    label: '项目简称',
    field: 'projectShortName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目简称!'},
             ];
    },
  },
  {
    label: '项目名',
    field: 'projectName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目名!'},
             ];
    },
  },
  {
    label: '主管部门',
    field: 'deptId',
    component: 'JSelectDept',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入主管部门!'},
             ];
    },
  },
  {
    label: '金科项目经理',
    field: 'projectManager',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入金科项目经理!'},
             ];
    },
  },
  {
    label: '项目负责人',
    field: 'projectOwner',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目负责人!'},
             ];
    },
  },
  {
    label: '行方负责人',
    field: 'bankOwner',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入行方负责人!'},
             ];
    },
  },
  {
    label: '测试负责人',
    field: 'testOwner',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入测试负责人!'},
             ];
    },
  },
  {
    label: '项目所属',
    field: 'projectOwnCata',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "project_own_cata"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目所属!'},
             ];
    },
  },
  {
    label: '项目分类',
    field: 'projectCata',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "project_cata"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目分类!'},
             ];
    },
  },
  {
    label: '软开科室',
    field: 'department',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入软开科室!'},
             ];
    },
  },
  {
    label: '业务部门',
    field: 'businessUnit',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入业务部门!'},
             ];
    },
  },
  {
    label: '启用状态',
    field: 'status',
    component: 'JSwitch',
    componentProps:{
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入启用状态!'},
             ];
    },
  },
  {
    label: '重点项目',
    field: 'importantProject',
    component: 'JSwitch',
    componentProps:{
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入重点项目!'},
             ];
    },
  },
  {
    label: '开始时间',
    field: 'startTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开始时间!'},
             ];
    },
  },
  {
    label: '结束时间',
    field: 'endTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入结束时间!'},
             ];
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectCode: {title: '项目编号',order: 0,view: 'text', type: 'string',},
  projectShortName: {title: '项目简称',order: 1,view: 'text', type: 'string',},
  projectName: {title: '项目名',order: 2,view: 'text', type: 'string',},
  deptId: {title: '主管部门',order: 3,view: 'sel_depart', type: 'string',},
  projectManager: {title: '金科项目经理',order: 4,view: 'sel_user', type: 'string',},
  projectOwner: {title: '项目负责人',order: 5,view: 'sel_user', type: 'string',},
  bankOwner: {title: '行方负责人',order: 6,view: 'text', type: 'string',},
  testOwner: {title: '测试负责人',order: 7,view: 'sel_user', type: 'string',},
  projectOwnCata: {title: '项目所属',order: 8,view: 'list', type: 'string',dictCode: 'project_own_cata',},
  projectCata: {title: '项目分类',order: 9,view: 'list', type: 'string',dictCode: 'project_cata',},
  department: {title: '软开科室',order: 10,view: 'text', type: 'string',},
  businessUnit: {title: '业务部门',order: 11,view: 'text', type: 'string',},
  status: {title: '启用状态',order: 12,view: 'switch', type: 'string',},
  importantProject: {title: '重点项目',order: 13,view: 'switch', type: 'string',},
  startTime: {title: '开始时间',order: 14,view: 'date', type: 'string',},
  endTime: {title: '结束时间',order: 15,view: 'date', type: 'string',},
  description: {title: '描述',order: 16,view: 'textarea', type: 'string',},
  createBy: {title: '创建人',order: 17,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 18,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 19,view: 'text', type: 'string',},
  updateTime: {title: '更新时间',order: 20,view: 'datetime', type: 'string',},
};
